<!doctype html>
<html lang="zh_cn" itemscope itemtype="http://schema.org/Person">
<head>
            <meta charset="utf-8">
        <!-- Site Meta Data -->
        <title>[原创]Ubuntu突然无法进入系统问题排查</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="技术博客,涉及Java/PHP/Python/Javascript等,聊聊程序,聊聊生活,聊聊事实,聊聊育儿">
        <meta name="keywords" content="编码经验,技术分享,生活积累,实事评说">
        <meta name="author" content="布丁缘">

        <link rel="shortcut icon" href="">

        <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>
        <!-- Style Meta Data -->
        <link rel="stylesheet" href="https://www.ddkiss.com/theme/css/style.css" type="text/css"/>
        <link rel="stylesheet" href="https://www.ddkiss.com/theme/css/pygments.css" type="text/css"/>

        <!-- Feed Meta Data -->
            <link href="https://www.ddkiss.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate"
                  title="一个程序员的简单生活 ATOM Feed"/>


    <meta name="keywords" content="">
    <link rel="stylesheet" href="//dn-coding-net-public-file.qbox.me/Coding-Comments/v0.1.0/default.css">
</head>

<body>
<!-- Sidebar -->
<aside>
    <center><h1><a href="/" style="color:#fff"><img id="avatar" src="/images/avatar.jpg"></a></h1></center>
        <p>一个程序员的简单生活</p>
    <br>
    <nav class="nav">
        <ul class="list-bare">
                <li><a class="nav__link" href="https://www.ddkiss.com/category/chang-yong-ji-qiao.html">常用技巧</a></li>
                <li><a class="nav__link" href="https://www.ddkiss.com/category/kai-fa-huan-jing.html">开发环境</a></li>
                <li><a class="nav__link" href="https://www.ddkiss.com/category/sheng-huo-dian-di.html">生活点滴</a></li>

                <li><a class="nav__link" href="/pages/books.html">书单</a></li>
                <li><a class="nav__link" href="/pages/movies.html">影单</a></li>
                <li><a class="nav__link" href="/pages/downloads.html">下载</a></li>
                <li><a class="nav__link" href="/pages/about.html">关于我</a></li>


        </ul>
    </nav>


    <form>
      <input type="text"  id="bdcsMain"/>
    </form>

</aside>

<!-- Content -->
<article>
  <main>
    <nav>
      <a href="/">首页</a>
      <a href="/archives.html">归档</a>
      <a href="/categories.html">分类</a>
      <a href="/tags.html">标签</a>
      <a href="/pages/about.html">关于我</a>
    </nav>
  </main>
    <section id="content">
        <article>
            <h2 class="post_title post_detail"><a href="https://www.ddkiss.com/archives/24.html" rel="bookmark"
                                                  title="Permalink to [原创]Ubuntu突然无法进入系统问题排查">[原创]Ubuntu突然无法进入系统问题排查</a></h2>

            <div class="post_list">
                <span>作者：</span><a href="https://www.ddkiss.com/author/bu-ding-yuan.html">布丁缘</a>
                <span class="post_category">分类：<a href="https://www.ddkiss.com/category/kai-fa-huan-jing.html" rel="bookmark"
                                               title="Permalink to 开发环境">开发环境</a></span>
                <span class="post_date">  时间：2017-09-25 17:56:00</span>

            </div>
            <div class="entry-content blog-post">
                <h2>背景</h2>
<p>今天早上像往常一样打开电脑，却发现连登陆页都无法显示出来，直接是灰屏。第一反应是，完了，不会是新换的SSD坏了吧？</p>
<h2>排查过程</h2>
<h3>1. 切换到命令行模式</h3>
<p>发现报错，“-bash /dev/null Permission denied”，然后去网上找，说执行"sudo chmod 777 /dev/null"就可以了。切回图形界面还是老样子。查看了 /var/log/kernel.log后也没看出什么问题。</p>
<h3>2. 切换到原来12.04的系统</h3>
<p>发现一切正常，基本排除了SSD和内存有问题的可能。期间还不放心用Memtest对内存做了次测试。</p>
<h3>3. 网上寻求解决方案</h3>
<p>然后看到有网友说用"startx"开启图像界面，试验后发现不行。后又有网友说ubuntu是用lightdm管理桌面，需要用"sudo service lightdm start"进入。经过实践发现，我必须先用"sudo chmod 777 /dev/null"，然后再用"sudo service lightdm <strong>restart</strong>"来启动，总算进入了图形登陆界面。</p>
<h3>4. 各种诡异</h3>
<p>可是这个界面很多东西很诡异，比如打开 Terminal 也提示"getap permission denied"。正毫无头绪时突然找到了一个网页<a href="http://www.linuxquestions.org/questions/ubuntu-63/bash-dev-null-permission-denied-on-ubuntu-login-481000/">"bash: /dev/null: Permission denied" on Ubuntu Login</a>。跟我的问题很类似，有人回答提到了<code>The permissions on /dev/null should be set by udev so check the files in /etc/udev/rules.d, such as /etc/udev/rules.d/40-permissions.rules,</code>让我恍然大悟。貌似我昨天也修改过类似的配置文件</p>
<h3>5. 找到真凶</h3>
<p>大概回忆了下，昨天为魅族手机配置MTP，需要在文件/lib/udev/rules.d/69-libmtp.rules 添加一些内容，而我直接贴到了文件的末尾。仔细看了下脚本，确实不应该放到结尾，而是应该接着其余手机配置项。真是大意了。应该放在这些内容之前。</p>
<blockquote>
<p>#Autoprobe vendor-specific, communication and PTP devices
    ENV{ID_MTP_DEVICE}!="1", ENV{MTP_NO_PROBE}!="1", ENV{COLOR_MEASUREMENT_DEVICE}!="1", ENV{libsane_matched}!="yes",         ATTR{bDeviceClass}=="00|02|06|ef|ff", PROGRAM="mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"</p>
</blockquote>
<div class="highlight"><pre><span></span>LABEL=&quot;libmtp_rules_end&quot;
</pre></div>


<h2>总结</h2>
<p>Ubuntu这种系统基于配置文件，如果配置文件出错会产生非常大的影响。比如PATH配错了，不重启系统还不会发现问题。所以，修改配置文件要谨慎！</p>
            </div>
            <div class="post_list">
              <div><span>Tags : </span>
              </div>
            </div>
        </article>
        <div id="container"></div>
        <script type="text/javascript" src="//dn-coding-net-public-file.qbox.me/Coding-Comments/v0.1.0/gitment.min.js"></script>
        <script>
            var gitment = new Gitment({
              owner: 'whusl',
              repo: 'BlogComments',
              oauth: {
                client_id: '621866266817529fba46681653017809',
                client_secret: '14188411740b12ae52159cee9b586bf85cd54125',
              },
            })
            document.getElementById('container').appendChild(gitment.render())
          </script>
    </section>
</article>

<!-- Footer -->
    <footer>
        <p> &copy;2017-2020&nbsp;<a href="http://www.miitbeian.gov.cn/" target="_blank">鄂ICP备17020200号</a>
          Blog powered by <a href="http://getpelican.com/">Pelican</a>
        </p>
    </footer>

    <!-- Analytics -->
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?88c55edaf311dbacac56a16316b04c8b";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

<script type="text/javascript">(function(){document.write(unescape('%3Cdiv id="bdcs"%3E%3C/div%3E'));var bdcs = document.createElement('script');bdcs.type = 'text/javascript';bdcs.async = true;bdcs.src = 'http://znsv.baidu.com/customer_search/api/js?sid=14490611060029767912' + '&plate_url=' + encodeURIComponent(window.location.href) + '&t=' + Math.ceil(new Date()/3600000);var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(bdcs, s);})();</script>

</body>
</html>